import sqlite3
import sys
import os

conn = None
cursor = None

class Table(object):
	

class Log(object):
	def __init__(self):
		pass
		
	def get_all(self):
		cursor.execute("SELECT * FROM timer_log")
		return cursor.fetchall()
		
	def add(self, created, hours, minutes, seconds, comment):
		cursor.execute("INSERT INTO timer_log (created, hours, minutes, seconds, comment) VALUES (:created, :hours, :minutes, :seconds, :comment)",
			{'created': created, 'hours': hours, 'minutes': minutes, 'seconds': seconds, 'comment': comment})
		conn.commit()

conn = sqlite3.connect(os.path.join(sys.path[0], 'db'))
cursor = conn.cursor()
cursor.execute("CREATE TABLE IF NOT EXISTS timer_log(id integer primary key, created datetime, hours, minutes, seconds, comment)")
conn.commit()

#l = Log()
#print l.get_all()

#conn.close()
